/*	kd:
	This Nithor is outdated. You can find the actually used one in
	
	shop/base shop/nithor.txt */

class GC_NithorSprite : Actor {
    Default {
        // +NOBLOCKMAP
        +FLOATBOB
        -SOLID
		+DONTSPLASH
		+DONTBLAST
		+NOGRAVITY
		+NOTIMEFREEZE

        Radius 0;
        Height 0;
        RenderStyle "Translucent";
        Scale 0.0; //Scale 0.2666;
        FloatBobStrength 0.1337;
        Alpha 0.9;
    }

    Actor aura;

    States {
    Spawn:
    Welcome:
    HelloAgain:
        TNT1 A 4;
        TNT1 A 0 {
            bool spawn_ok = false;
            aura = Spawn("GC_NithorAura", pos);
            
            if(aura != null) {
                aura.target = self;
                aura.angle = angle;
            }
        }

        NITH N 0 A_SpawnItemEx("GC_NithorAppears", 0, 0, 10);
		NITH N 1 {
			A_SetScale(Scale.X + 0.01333);
			Return A_JumpIf(Scale.X >= 0.2666, 1);
		}
		Wait;
		NITH N 35;
    Idle:
        NITH A Random(10, 150);
        NITH A 10 A_Jump(220, "DoSomething");
        Loop;
    DoSomething:
        NITH A 2 A_Jump(100, "Blink");
        NITH A 2 A_Jump(60, "TapKnee");
        Goto LookAround;
    
    /*TryBreakOut:
        NITH K 12;
    BreakOutLoop:
        NITH K 4 {

        }*/
    
    Blink:
        NITH B 4;
        NITH A 4;
        NITH A 4 A_Jump(180, "BlinkAgain");
        Goto Idle;
    BlinkAgain:
        NITH B 4;
        NITH A 4;
        NITH A 4 A_Jump(40, "BlinkAgain");
        Goto Idle;
    
    TapKnee:
        NITH AEAEAE 7;
        NITH E 10 A_Jump(180, "Blink");
        Goto Idle;
    
    LookAround:
        NITH C 30;
        NITH A 5;
        NITH D 30;
        NITH A 5 A_Jump(180, "TapKnee");
        Goto Idle;
    
    Scoff:
        NITH C 40;
        NITH A 10;
        Goto Idle;
    
    ThumbsUp:
        NITH G 80; // TODO: Add sparkle
        NITH A 10;
        Goto Idle;

    BurningTime:
        NITH M 150 {
            bool spawn_ok;
            Actor fire;

            for(int i = 0; i < 5; i++) {
                [spawn_ok, fire] =
                    A_SpawnItemEx("GC_NithorAgitationFire", 10, 0, 20);
                
                if(spawn_ok) {
                    fire.roll = 30 * (i - 2);
                }
            }
        }
        Goto Idle;
        
    ByeBye:
        NITH G 20;
        NITH G 0 {
            A_SpawnItemEx("GC_NithorAppears", 0, 0, 10);
			
			if(aura) {
				aura.Destroy();
			}
        }
        Stop;

    Leaving:
		NITH E 0 A_SetScale(0.2666);
        NITH G 25;
        NITH G 0 {
            A_SpawnItemEx("GC_NithorAppears", 0, 0, 10);
			
			if(aura) {
				aura.Destroy();
			}
        }
		NITH G 1 {
			A_SetScale(Scale.X * 0.95);
			Return A_JumpIf(Scale.X <= 0.15, "Null");
		}
        Wait;
    }
}
